// 游戏结束请运行：
// finalDlg->setModal(true);
// finalDlg->exec();

#ifndef GAMEWINDOW_H
#define GAMEWINDOW_H

#include <math.h>

#include <QDebug>
#include <QMouseEvent>
#include <QPainter>
#include <QPixmap>
#include <QPushButton>
#include <QSound>
#include <QWidget>

#include "board.h"
#include "finaldlg.h"
#include "game.h"

namespace Ui {
class GameWindow;
}

class GameWindow : public QWidget {
    Q_OBJECT

   public:
    explicit GameWindow(QWidget *parent = nullptr);
    GameWindow(int gameType, int difficulty, int order);  // gameType:人机对战为0，人人对战为1；order:先手为0，后手为1；
    void paintHistory();
    void returnHome();
    ~GameWindow();

    Ui::GameWindow *ui;
    Game *game;
    FinalDlg *finalDlg;
    Board *board;
    QPainter *paint;
    QPushButton *returnBtn;
    QPushButton *withdrawBtn;
    QLabel *now;
    QLabel *whichPlayer;

    int clickPosRow, clickPosCol;  //存储点击位置
    int once;                      // 控制游戏结束一次
    int over;                      // 游戏结束状态
    int recapMode;                 // 回顾棋局模式

    void paintEvent(QPaintEvent *);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void chessOneByPerson();
    void chessOneByAi();
    void blackWin();
    void whiteWin();
    void flipPlayer();
    void withdraw();

   signals:
    void showMain();
    void setBlack();
    void setWhite();
};

#endif  // GAMEWINDOW_H
